object Underscore {
  def main(args: Array[String]): Unit = {
//    println(matchValue(1))

//    //第二种
//    Some(5) match {
//      case Some(_) => println("is ok")
//    }

    //第三种
//    List(1,2,3,4,5,6).foreach(print(_))
//    List(1,2,3,4,5,6) foreach{_ => print("ok")}
//    List(1,2,3,4,5,6) foreach{a => print(a)}

    //第四种
    import scala.util.Try._


    //第五种测试
//    val t = new Test
//    t.age = 5
//    println(t.age)

    //第六种
    List(1,2,3,4,5,6).map(_ + 2)
    List(1,2,3,4,5,6).filter(_%2 == 0)
    List(1,2,3,4,5,6).reduce(_+_)
    List(1,2,3,4,5,6).exists(_ > 3)

    //第七种 函数赋值
//    var s = prt
//    println(s)

    val f = prt _
    println(f())




  }

  //第一种
  def matchValue(x:Int):String = x match {
    case 1 => "one"
    case 2 => "two"
    case _ => "anything else"
  }

  //第五种
  class Test{
    private var a = 0

    //get操作
    def age = a

    //set操作
    def age_=(n:Int) = {
      require(n>0)
      a =n
    }
  }

  //第七种
  def prt:String = {println("call");"ok"}

}
